package com.gopay.common.cps.dao.wallet.promotions.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.wallet.promotions.WaPromotionsParamDao;
import com.gopay.common.domain.dps.WaPromotionsParam;
/**
 * 
 * @author dps
 *
 */
@Repository("waPromotionsParamDao")
public class WaPromotionsParamDaoImpl extends BaseDAOImpl<WaPromotionsParam, Integer> implements WaPromotionsParamDao {
	protected Logger logger = LoggerFactory.getLogger(WaPromotionsParamDaoImpl.class);

	@Override
	public List<WaPromotionsParam> queryPromotionsParamsByCondition(Map<String, Object> params) {
		String hql = "from WaPromotionsParam t where 1=1";
		for( Map.Entry<String, Object> entry : params.entrySet() ){
			hql += " AND t."+entry.getKey()+"=:"+entry.getKey();
		}
		return this.findByHql(hql, params);
	}
	@Override
	public List<WaPromotionsParam> querryByParamKeys(String[] paramKeys) {
		String hql = "from WaPromotionsParam t where t.paramKey in (:paramKeys) ";
		Map param = new HashMap();
		param.put("paramKeys", paramKeys);
		List<WaPromotionsParam> res = this.findByHql(hql, param);
		if (res != null && res.size() > 0) {
			return res;
		}
		return null;
	}
}
